package ch.sfug.graphics.primitives 
{
	import flash.display.Shape;				

	public class SimpleColorStar extends Shape {
		public function SimpleColorStar(color, alphaValue, points, outerRadius, innerRadius, circleX, circleY, phaseShift) {
			setUI(color, alphaValue, points, outerRadius, innerRadius, circleX, circleY, phaseShift);
		}

		
		private function setUI(color, alphaValue, p, er, ir, cx, cy, ps):void {	
			alpha = alphaValue;
			graphics.beginFill(color);
	        
			if (ps == undefined) {
				if (p % 2) {
					ps = -Math.PI / 2;
				} 
			  else if ((p - 6) % 4 == 0) {
					ps = 0;
				} 
			  else {
					ps = Math.PI / p;
				}
			}
			 
			var i:Number = 2 * Math.PI / p;
			var j:Number = i / 2;
			var ts:Number;
			for (var t:Number = 0;t < 2 * Math.PI; t += i) {
				ts = t - ps;
				graphics[t ? "lineTo" : "moveTo"](cx + Math.cos(ts) * er, cy + Math.sin(ts) * er);
				graphics.lineTo(cx + Math.cos(ts + j) * ir, cy + Math.sin(ts + j) * ir);
			}
			 
			graphics.lineTo(cx + Math.cos(ps) * er, cy + Math.sin(-ps) * er);			
		}
	}
}